// pages/xiaoxi/index/index.js
const app=getApp()
const myRequest = require("../../../utils/require.js")
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userInfo:'',
    shenhe:0,
    overdue:0,
    update:0,
    notice:0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    app.CheckSession().then(res => {
      if (res == true) {
        app.GetUser().then(data => {
          this.apiRequest()
          this.setData({
            userInfo: data
          })
        })
      }
    })
  
  },
  apiRequest() {
    myRequest.myRequest('User/userNotify', {  }, 'GET').then(success => {
      this.setData({
        shenhe: success.data.shenhe,
        overdue: success.data.overdue,
        update: success.data.update,
        notice: success.data.notice,
       
      })
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.apiRequest()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  Shenppi(e){
      if(this.data.userInfo.role_id!=3){
        wx.navigateTo({
          url: '/pages/xiaoxi/shenpi/index',
          success: function (res) { },
          fail: function (res) { },
          complete: function (res) { },
        })
      }
      if(this.data.userInfo.role_id==3){
          wx.navigateTo({
            url: '/pages/xiaoxi/shenpi/mine/index',
          })
      }
  },
  Daigengxin(e){
    wx.navigateTo({
      url: '/pages/xiaoxi/daigengxin/index',
      success: function(res) {},
      fail: function(res) {},
      complete: function(res) {},
    })
  },
  Gonggao(e){
    wx.navigateTo({
      url: '/pages/xiaoxi/gonggao/index',
      success: function(res) {},
      fail: function(res) {},
      complete: function(res) {},
    })
  },
  Paihang(e){
    wx.navigateTo({
      url: '/pages/xiaoxi/paihang/index',
      success: function(res) {},
      fail: function(res) {},
      complete: function(res) {},
    })
  },
  Guoqi(e){
    wx.navigateTo({
      url: '/pages/xiaoxi/guoqi/index',
      success: function(res) {},
      fail: function(res) {},
      complete: function(res) {},
    })
  }
})